<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="pure-min.css">        
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        include("config.php");
        session_start();
        if ($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from Form 
            $myusername = addslashes($_POST['username']);
            $mypassword = addslashes($_POST['password']);

            $sql = "SELECT id FROM admin WHERE username='$myusername' and passcode='$mypassword'";
            $result = mysql_query($sql);
            $row = mysql_fetch_array($result);
            $count = mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
            if ($count == 1) {
                $_SESSION['login_user'] = $myusername;

                header("location: welcome.php");
            } else {
                $error = "Utente non riconosciuto";
                print "<script type=\"text/javascript\">";
                print "alert('Utente non riconosciuto')";
                print "</script>";
            }
        }
        ?>
        <div class="pure-g">
            <div class="pure-u-1-3"></div>
            <div class="pure-u-1-3"> 
                <form  class="pure-form pure-form-stacked" action="" method="post">  
                    <fieldset>
                        <label for="username">Username</label>
                        <input type="text" name="username" placeholder="login" required/><br />    
                        <label for="password">Password</label>
                        <input type="password" name="password" placeholder="password" required/><br/>
                        <input type="submit" value="ENTRA" class="pure-button pure-button-primary"/>                        
                        <br />
                    </fieldset>
                </form>  
            </div>
            <div class="pure-u-1-3"></div>
        </div>      
    </body>
</html>
